package com.yylending.las.lending.increase;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.Loader;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.yyfax.infrastructure.mvp.Presenter;
import com.yylending.las.R;
import com.yylending.las.base.BaseActivity;

/**
 * Created by Pengrf on 2017/11/20.
 * Copyright  2017 www.yyfax.com. All Rights Reserved.
 */
public class FinishPromoteProcessActivity extends BaseActivity {
	private static final String RESULT_CODE = "FINISHPROMOTEPROCESSACTIVITY_RESULT_CODE";
	/**
	 * 图
	 */
	@BindView(R.id.increase_result_iv)
	ImageView mIncreaseResultIv;
	/**
	 * 文字1
	 */
	@BindView(R.id.increase_result_text1)
	TextView mIncreaseResultText1;
	/**
	 * 文字2
	 */
	@BindView(R.id.increase_result_text2)
	TextView mIncreaseResultText2;
	/**
	 * 按钮
	 */
	@BindView(R.id.increase_result_submit_btn)
	Button mIncreaseResultSubmitBtn;

	private String mCode = "";

	@Override
	public void onLoadFinished(Loader<Presenter> loader, Presenter data, int placeholder) {

	}

	@Override
	public Loader<Presenter> onCreateLoader(int id, Bundle args) {
		return null;
	}

	public static void start(Activity activity, CheckPromoteStatusModel.PromoteStatus promoteStatus) {
		Intent intent = new Intent(activity, FinishPromoteProcessActivity.class);
		intent.putExtra(RESULT_CODE, promoteStatus.code);
		activity.startActivity(intent);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_increase_result2);
		ButterKnife.bind(this);
		initView(savedInstanceState);
	}

	private void initView(Bundle savedInstanceState) {
		mCode = savedInstanceState.getString(RESULT_CODE);
		switch (mCode) {
			case "error":    //多种状态信息(可重新发起)
				break;
			case "promoteCompleted":    //提额成功
				mIncreaseResultIv.setImageDrawable(this.getResources().getDrawable(R.drawable.ic_increase_limit_success));
				mIncreaseResultText2.setVisibility(View.GONE);
				mIncreaseResultText1.setText(R.string.check_success);
				mIncreaseResultSubmitBtn.setText(R.string.check_limit);
				break;
			case "promoteFailed":    //提额失败
				mIncreaseResultIv.setImageDrawable(this.getResources().getDrawable(R.drawable.ic_increase_limit_failure));
				mIncreaseResultText2.setVisibility(View.VISIBLE);
				mIncreaseResultText1.setText(R.string.sorry_increase_failure);
				mIncreaseResultText2.setText(R.string.sorry_increase_failure2);
				mIncreaseResultSubmitBtn.setText(R.string.complete);
				break;
			case "success":    //没有任何保单信息，可以提交提额
				break;
			default:
				break;
		}
	}
}
